package de.java.hsrm.factory;

import java.awt.*;

import javax.swing.JButton;

@SuppressWarnings("serial")
public class TestButton extends JButton{

	public TestButton(String text){
		super(text);
		setContentAreaFilled(false);
		setForeground(Color.LIGHT_GRAY);
	}

	
	@Override protected void paintComponent(Graphics g){
		Graphics2D g2 = (Graphics2D) g;
		
		Composite oldComp = g2.getComposite();
		
		g2.setComposite(AlphaComposite.SrcOver.derive(0.5f));
		g2.setColor(Color.BLACK);
		g2.translate(5, 5);
		g2.fillRect(0, 0, 100, 100);
		g2.translate(-5, -5);
		g2.setComposite(oldComp);
		
		GradientPaint p = new GradientPaint(0,0,new Color(0x555555),
				0,10,new Color(0x333333));
		g2.setPaint(p);
		g2.fillRect(0, 0, getWidth(), getHeight()/2);
		
		p = new GradientPaint(0,10,new Color(0x222222),
				0,20,new Color(0x111111));
		g2.setPaint(p);
		g2.fillRect(0, getHeight()/2, getWidth(), getHeight()/2);
		
		if(getModel().isRollover()){
			g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
			g2.setBackground(Color.BLACK);
			
		}
		
		super.paintComponent(g);
	}
}

